# $Id$
# Maintainer: Stéphane Gaudreault <stephane@archlinux.org>
# Maintainer: Tobias Powalowski <tpowa@archlinux.org>
# Contributor: Aaron Griffin <aaron@archlinux.org>

pkgname=iputils
# Commit date + git rev-parse --short origin/master
_rev=f6aac8d
pkgver=20180629.${_rev}
pkgrel=2
pkgdesc="Network monitoring tools, including ping"
arch=('x86_64')
license=('GPL')
url="http://www.skbuff.net/iputils/"
groups=('base')
depends=('openssl' 'libcap' 'libidn2')
optdepends=('xinetd: for tftpd')
makedepends=('perl-sgmls' 'git' 'docbook-xsl')
conflicts=('netkit-base' 'arping' 'netkit-tftpd')
replaces=('netkit-base')
backup=(etc/xinetd.d/tftp)
install=${pkgname}.install
source=("git+https://github.com/iputils/iputils.git#commit=${_rev}"
        tftp.xinetd)
sha1sums=('SKIP'
          'fc2ae26f5609725e3f4aeaf4ab82dfa6d2e378fd')

build() {
  cd "${srcdir}/${pkgname}"

  make USE_NETTLE=no USE_GNUTLS=no CCOPTOPT="$CFLAGS"
  # fix perl-sgmls
  sed -i -e 's#sgmlspl#sgmlspl.pl#g' "${srcdir}/${pkgname}/doc/Makefile"
  make -C doc man
}

package() {
  cd "${srcdir}/${pkgname}"

  install -dm755 "${pkgdir}"/usr/bin

  install -m755 arping clockdiff ping rarpd rdisc tftpd tracepath "${pkgdir}"/usr/bin/

  install -dm755 "${pkgdir}"/usr/share/man/man8
  install -m644 doc/{arping,clockdiff,ping,rarpd,rdisc,tftpd,tracepath}.8 \
     "${pkgdir}"/usr/share/man/man8/

  # FS#24768
  install -dm755 "${pkgdir}"/etc/xinetd.d/
  install -m644 "${srcdir}"/tftp.xinetd "${pkgdir}"/etc/xinetd.d/tftp
}
